﻿using Ecommerce.API.Application.Command.RoleCommand;
using MediatR;
using Ecommerce.Domain.User;
using Ecommerce.Services.User;

namespace Ecommerce.API.Application.CommandHandlers.RoleHandler
{
    public class AccountAddCommandHandler :IRequestHandler<AccountAddCommand, int>
    {
        private readonly IUseInfoServices services;

        public AccountAddCommandHandler(IUseInfoServices services)
        {
            this.services = services;
        }

        public async Task<int> Handle(AccountAddCommand request, CancellationToken cancellationToken)
        {
            return await services.AddAccount(new Account() { Rid = request.Rid, Tid = request.Tid, UserName = request.UserName, UseSex = request.UseSex, Address = request.Address });
        }
    }
}
